package com.itheima.employee.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.common.entity.PageResult;
import com.itheima.employee.mapper.ArchiveMapper;
import com.itheima.employee.pojo.EmployeeArchive;
import com.itheima.employee.service.ArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;

/**
 * @author qiankaofei
 * @version 1.0
 * @date 2020/11/16 10:45
 */
@Service
@Transactional
public class ArchiveServiceImpl implements ArchiveService {

    @Autowired
    private ArchiveMapper archiveMapper;


    /**
     * 保存归档记录
     * @param archive
     */
    @Override
    public void save(EmployeeArchive archive) {

    }

    /**
     *
     * @param companyId
     * @param month
     * @return
     */
    @Override
    public EmployeeArchive findLast(String companyId, String month) {
        return null;
    }


    /**
     * 分页查询历史归档记录
     */
    @Override
    public PageResult<EmployeeArchive> findSearch(String year,String companyId, Integer page, Integer pagesize) {
        PageHelper.startPage(page,pagesize);
        //查询
        List<EmployeeArchive> employeeArchiveList=archiveMapper.findSearch(year,companyId);
        PageInfo<EmployeeArchive> pageInfo=new PageInfo<EmployeeArchive>(employeeArchiveList);
        return new PageResult<EmployeeArchive>(pageInfo.getTotal(),pageInfo.getList());
    }
}
